package com.bkgy.controller.tPdiDataL3Tcm2280.controller;

import com.bkgy.commom.model.BaseRangeObj;
import com.bkgy.controller.tPdiDataL3Tcm2280.entity.pdo.RepOutputReasonReq;
import com.bkgy.controller.tPdiDataL3Tcm2280.entity.pdo.RepOutputReasonRes;
import com.bkgy.controller.tPdiDataL3Tcm2280.service.IRepTcmOutputHourService;
import com.bkgy.sys.common.entity.ResultData;
import com.bkgy.util.DateUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "酸轧小时产量统计", description = "酸轧小时产量统计")
@RestController
@RequiredArgsConstructor
@RequestMapping("/tcmOutputHour")
public class RepTcmOutputHourController {
    private final IRepTcmOutputHourService service;

    @ResponseBody
    @Operation(summary = "小时产量分析报表", description = "小时产量分析报表")
    @PostMapping("/outpurHourRep")
    public ResultData<RepOutputReasonRes> outpurHourRep(@RequestBody BaseRangeObj obj) {
        //转换日期格式
        String beginDate = DateUtil.tranceDateFormat(obj.getBeginDate(), "yyyy-MM-dd", "yyyyMMdd");
        String endDate = DateUtil.tranceDateFormat(obj.getEndDate(), "yyyy-MM-dd", "yyyyMMdd");
        return service.selectOutputHourRep(beginDate, endDate);
    }

    @Operation(summary = "更新小时原因", description = "更新小时原因，yyyyMMdd")
    @PostMapping("/updateReason")
    @ResponseBody
    public ResultData<String> updateReason(@RequestBody @Valid RepOutputReasonReq req) {
        return service.updateReason(req);
    }
}
